<template>
	<view class="content">
		<view class="member-list">
			<checkbox-group @change="change">
				<label class="member-item" v-for="(i,j) in list" :key="j">
					<view class="name">
						<checkbox :value="i.id" :checked="checkList.includes(i.id)" color="#FFCC33" style="transform:scale(0.7)" />
						<image src="../../../../../static/work.png" mode=""></image>
						<text>{{i.realname}}</text>
					</view>
					<view class="status">
						<text style="color: #98c379;">空闲</text>
					</view>
				</label>
			</checkbox-group>
		</view>
		<view class="footer">
			<text></text>
			<!-- <text @tap="reChange()">重选</text> -->
			<text @click="submit">确定</text>
		</view>
	</view>
</template>

<script>
	import api from "../../../../../network/index.js"
	export default {
		data() {
			return {
				list: [],
				checkList:['3429',]
			};
		},
		methods:{
			// 确定
			submit(){
				let pages = getCurrentPages()
				let page = pages[pages.length-2]
				let arr = []
				// 查询用户列表
				this.checkList.forEach(res=>{
					api.request({
						url: api.USER_LIST,
						isLoadding: false,
						data:{
							user_type_id: "=,1",
							id: "=,"+ (res-0)
						}
					}).then(res=>{
						if(res.data.code == "200"){
							let data = res.data.list.data[0]
							arr.push(data)
						}else{
							api.error(res)
						}
					}).catch(err=>{
						api.error(err)
					})
				})
				uni.$emit('fire', {
					data: arr
				});
				uni.navigateBack()
			},
			// 选择
			change(e){
				this.checkList = e.detail.value
			},
			// 取消选择
			reChange(){
				this.checkList = []
			},
			getMemberList(){
				api.request({
					url: api.USER_LIST,
					data:{
						user_type_id: "=,1"
					}
				}).then(res=>{
					// console.log(res)
					if(res.data.code == "200"){
						this.list = res.data.list.data
					}else{
						api.error(res)
					}
				}).catch(err=>{
					api.error(err)
				})
			}
		},
		onLoad(options) {
			this.getMemberList()
		}
	}
</script>

<style lang="scss" scoped>
page,.content{
	width: 100vw;
	height: 100vh;
	background-color: #FFFFFF;
}
.footer{
	position: fixed;
	display: flex;
	justify-content: space-between;
	bottom: 0;
	left: 0;
	right: 0;
	height: 100rpx;
	line-height: 100rpx;
	font-size: 32rpx;
	font-weight: 800;
	background-color: #FFFFFF;
	border-top: 1rpx solid #EEEEEE;
	text{
		width: 200rpx;
		text-align: center;
	}
}
.member-item{
	padding: 0 30rpx;
	display: flex;
	justify-content: space-between;
	height: 100rpx;
	line-height: 100rpx;
	font-size: 32rpx;
	border-top: 1rpx solid #EEEEEE;
	border-bottom: 1rpx solid #EEEEEE;
	view{
		display: flex;
		image{
			width: 80rpx;
			height: 80rpx;
			vertical-align: middle;
		}
	}
}
</style>
